// 领航宣讲

/**
 * 弹窗表单人员信息校验
 */
export const messageRules = {
  pictureId: [{ required: true, message: "请上传头像", trigger: "blur" }],
  userName: [
    { required: true, message: "请输入姓名", trigger: "blur" },
    { max: 20, message: "姓名不可超过20个字", trigger: "blur" },
  ],
  gender: [{ required: true, message: "请选择性别", trigger: "blur" }],
  companyName: [{ required: true, message: "请选择公司名称", trigger: "blur" }],
  partyOrgName: [{ required: true, message: "请选择支部", trigger: "blur" }],
  partyBranchPosition: [
    { required: true, message: "请输入职务", trigger: "blur" },
    { max: 20, message: "职务不可超过20个字", trigger: "blur" },
  ],
  phone: [
    { required: true, message: "请输入电话", trigger: "blur" },
    { pattern: /^((1[3456789]\d{9}))$/, message: "请输入正确的手机号码!" },
  ],
  briefIntroduction: [
    { required: true, message: "请输入个人简介", trigger: "blur" },
    { max: 200, message: "个人简介不可超过200个字", trigger: "blur" },
  ],
  lectureExperience: [
    { required: true, message: "请输入宣讲经验", trigger: "blur" },
    { max: 200, message: "宣讲经验不可超过200个字", trigger: "blur" },
  ],
  videoName: [{ required: true, message: "请输入视频附件", trigger: "blur" }],
  lectureTime: [{ required: true, message: "请选择宣讲时间", trigger: "blur" }],
  title: [
    { required: true, message: "请输入标题", trigger: "blur" },
    { max: 200, message: "标题不可超过200个字", trigger: "blur" },
  ],
  fileList: [{ required: true, message: "请输入附件", trigger: "blur" }],
  caseContent: [
    { required: true, message: "请输入案例内容", trigger: "blur" },
    { max: 1000, message: "案例内容不可超过1000个字", trigger: "blur" },
  ],
};
/**
 * 通用列标头
 */
const commonColumnHeader = [
  {
    label: "公司名称",
    prop: "companyName",
    width: "200",
  },
  {
    label: "支部",
    prop: "partyOrgName",
    width: "200",
  },
  {
    label: "标题",
    prop: "title",
    width: "150",
  },
  {
    label: "简介",
    prop: "briefIntroduction",
    width: "200",
  },
];
/**
 * 通用列状态
 */
const generalColumnState = [
  {
    label: "状态",
    prop: "currentNode",
    width: "180",
    formatterStatus: (row) => formatterStatus(row.currentNode),
  },
];
/**
 * 领航宣讲后台管理-表格信息表头
 * @param type 当前菜单类型
 */
export const tableColumnHead = (type) => {
  switch (type) {
    case "talentPool": // 人才库
      return [
        {
          label: "公司名称",
          prop: "companyName",
          width: "200",
        },
        {
          label: "支部",
          prop: "partyOrgName",
          width: "200",
        },
        {
          label: "姓名",
          prop: "userName",
          width: "100",
        },
        {
          label: "性别",
          prop: "gender",
          width: "80",
        },
        {
          label: "照片",
          prop: "pictureName",
          width: "180",
        },
        {
          label: "简介",
          prop: "briefIntroduction",
          width: "200",
        },
        ...generalColumnState,
      ];
    case "video": // 视频库
      return [
        ...commonColumnHeader,
        {
          label: "宣讲人姓名",
          prop: "userName",
          width: "100",
        },
        {
          label: "视频附件",
          prop: "videoName",
          width: "180",
        },
        {
          label: "宣讲时间",
          prop: "lectureTime",
          width: "150",
        },
        ...generalColumnState,
      ];
    case "lessonPlan": // 教案库
      return [
        ...commonColumnHeader,
        {
          label: "宣讲人姓名",
          prop: "userName",
          width: "100",
        },
        {
          label: "多附件",
          prop: "fileList",
          width: "180",
          formatterFile: (row) => row.fileList && formatterFile(row.fileList),
        },
        ...generalColumnState,
      ];
    case "case": // 案例库
      return [
        ...commonColumnHeader,
        {
          label: "宣讲人姓名",
          prop: "userName",
          width: "100",
        },
        {
          label: "宣讲时间",
          prop: "lectureTime",
          width: "150",
        },
        ...generalColumnState,
      ];
    case "literature": // 文献库
      return [
        {
          label: "标题",
          prop: "title",
          width: "180",
        },
        {
          label: "来源",
          prop: "source",
          width: "180",
        },
        {
          label: "关键词",
          prop: "keyWord",
          width: "180",
        },
        {
          label: "附件",
          prop: "fileList",
          width: "180",
          formatterFile: (row) => row.fileList && formatterFile(row.fileList),
        },
        ...generalColumnState,
      ];
  }
};

/**
 * 状态转换
 * @param status 当前状态
 */
export const formatterStatus = (status) => {
  switch (status) {
    case "DRAFT":
      return "拟稿";
    case "CITY_DIRECTOR_AUDIT":
      return "分公司党办主任审核";
    case "PROVINCE_PARTY_OPERATOR_APPROVAL":
      return "省公司党办经办人初审";
    case "PROVINCE_PARTY_LEADER_FINAL_APPROVAL":
      return "省公司党办负责人终审";
    case "END":
      return "已发布";
    case "CITY_LEADER_AUDIT":
      return "分管领导审核";
    default:
      return "草稿";
  }
};

/**
 * 附件转换
 * @param file 附件列表
 */
export const formatterFile = (file) => {
  // 获取到附件名称 用于展示
  return file.map((item) => item.fileName).join("，");
};

/**
 * 各类库对应的库名称
 * @param libraryTypeId 各类库的类型
 */
export const exportTemplateName = (libraryTypeId) => {
  switch (libraryTypeId) {
    case "talentPool":
      return "人才库";
    case "video":
      return "视频库";
    case "lessonPlan":
      return "教案库";
    case "case":
      return "案例库";
    case "literature":
      return "文献库";
  }
};

/**
 * 上传最终进度
 */
export const UPLOAD_FINAL_PROGRESS = 90;
/**
 * 上传后展示进度
 */
export const SHOW_PROGRESS_AFTER_UPLOAD = 99;
